<?php
	/**
	 * @author Matthias Eigner | 0625203
	 */
    abstract class Service {
        protected $name;
        protected $config;
        
        public function __construct() {
            $this->config = array();
        }
        
        public function loadConfig($file){
            if(is_file($file)){
                require_once($file);
            } else {
                //$this->sp->msg->run(array('message'=>str_replace(array('[%datei%]'), array($file), $this->_('FILE_NOT_FOUND')), 'type'=>Messages::INFO));
            }
        }
        
        protected function loadFile($file){ 
        	if(isset($file)){
                $filename = $file;
                if(!file_exists($filename)) {
                    return $this->_('FILE_NOT_FOUND'); 
                }
                if(!is_file($filename)) {
                    return $this->_('NO_FILE'); 
                }
                $file= fopen($filename,'r');
                if(filesize($filename) > 0) {
                    $text = fread($file,filesize($filename));
                    fclose($file);
                    return $text;
                } else return 'ERROR: File '.$filename.' ist leer';
                return (isset($args['file'])) ? loadFile($GLOBALS['config']['root'].$args['file']) : $this->sp->_('FILE_NOT_FOUND');
            } else return '';
        }
        
        protected function _($str, $service='core'){return isset($GLOBALS['Localization'][$service][$str][$GLOBALS['Localization']['language']]) ? $GLOBALS['Localization'][$service][$str][$GLOBALS['Localization']['language']] : '';}
    }
?>
